import 'dart:math';

import '../../common/index.dart';

class DemoMockApis {
  // 模拟获取Demo列表
  Future<List<Map<String, dynamic>>> getDemoList({
    required int page,
    bool isShowLoad = true,
  }) async {
    if (isShowLoad) {
      showNormalLoadMsg(msg: '加载中...');
    }

    List<Map<String, dynamic>> list = [];
    int star = (page - 1) * 20;
    int end = page * 20;
    for (int i = star; i < end; i++) {
      list.add({
        'title': 'Demo $i',
        'desc': 'Demo $i desc',
      });
    }
    int isHave = Random().nextInt(10);
    if (isHave == 1) {
      list = [];
    }
    await Future.delayed(const Duration(milliseconds: 500));
    if (isShowLoad) {
      loadDismiss();
    }

    return list;
  }
}
